<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>财税客户平台</title>
    <link rel="stylesheet" href="style/css/layui/layui.css">
    <script src="style/js/layui/layui.js"></script>
    <script src="style/js/cookie.js"></script>
    <script src="style/js/jquery-3.2.1.min.js"></script>
    <style>

        .one-manu-text {
            font-size: 13px;
        }

        .two-manu-text {
            font-size: 12px;
            margin-left: 15px;
        }

        .layui-form-label {
            float: left;
            padding: 0px 0px;
            width: 80px;
            font-weight: 400;
            line-height: 20px;
            text-align: left;
        }

        .layui-nav .layui-this:after, .layui-nav-bar, .layui-nav-tree .layui-nav-itemed:after {
            position: absolute;
            left: 0;
            top: 0;
            width: 0;
            height: 5px;
            background-color: #23262E;
            transition: all .2s;
            -webkit-transition: all .2s;
        }

        .layui-input, .layui-select, .layui-textarea {
            height: 23px;
            line-height: 1.3;
            line-height: 30px \9;
            border-width: 1px;
            border-style: solid;
            background-color: #fff;
            border-radius: 4px;
            width: 140px;
        }

        select { /*Chrome和Firefox里面的边框是不一样的，所以复写了一下*/
            border: solid 1px #000; /*很关键：将默认的select选择框样式清除*/
            appearance: none;
            -moz-appearance: none;
            -webkit-appearance: none; /*在选择框的最右侧中间显示小箭头图片*/
            background: url("http://ourjs.github.io/static/2015/arrow.png") no-repeat scroll right center transparent; /*为下拉小箭头留出一点位置，避免被文字覆盖*/
            padding-right: 14px;
        }

        /*清除ie的默认选择框样式清除，隐藏下拉箭头*/

        select::-ms-expand {
            display: none;
        }

        select option {
            text-indent: 10px;
        }

        select option:hover {
            background-color: #f80;
            color: #fff;
        }

        button, input, optgroup, option, select, textarea {
            height: 24px;
            font-family: inherit;
            font-size: inherit;
            font-style: inherit;
            font-weight: inherit;
            outline: 0;
            background-color: #eeeeee;
        }

        .layui-form-select .layui-input {
            width: 220px;
            border-radius: 0;
        }

        .layui-form-select dl {
            max-height: 100px;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo" style="font-size: 20px;font-weight: bold">财税客户平台</div>
            <!-- 头部区域（可配合layui已有的水平导航） -->
            <ul class="layui-nav layui-layout-right" style="font-size: 16px;">
                <li class="layui-nav-item" style="margin-left: 10px;">
                    <!--                    <label class="layui-form-label" style="font-size: 12px;margin-left: 10px;transform: translate(28px 0px)!important;">登陆人:</label>-->
                    <!--                    <label class="layui-form-label" id="dengluName1" style="width: 90px;font-size: 12px;"></label>-->
                    <span style="font-size: 12px;">登陆人：</span> <span style="font-size: 12px;" id="dengluName"></span>
                </li>
                <!--                添加一个空格，使登陆人与公司名称中间有一定的间隙-->
                <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                <li class="layui-nav-item" style="margin-right: 20px">
                    <span style="font-size: 12px;">公司名称：</span>
                    <span style="font-size: 12px;" id="companyName1"></span>
                    <span style="font-size: 12px;color: #60c7d0" id="qieHuan">&nbsp;切换</span>
                </li>
                <li class="layui-nav-item"><a href="javascript:;" onclick="logout()" style="font-size: 12px;">退出登录</a>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">

            </div>
        </div>
        <div class="layui-body">
            <div class="layui-container" style="width: 100%">
                <div style="padding: 0px;">
                    <iframe id="iframeMain" style="width:100%;height:830px;" frameborder="0"></iframe>
                </div>
            </div>
        </div>
        <div class="layui-footer">
            <!-- 底部固定区域 -->
            © 助力耶微信公众平台
        </div>
    </div>
</div>
<!--切换公司弹出-->
<div id="qieHuanCompany" class="layui-form" style="font-size: 12px;margin: auto;display: none">
    <form class="layui-form" action="">
        <div style="margin-top: 20px">
            <span style="font-size: 13px;font-weight: bold;margin-left: 10px;margin-top: 20px">切换公司</span>
        </div>
        <div style="width: 100%;height: 1px;background-color: #dddddd;margin-top: 5px"></div>
        <div class="layui-form-item" style="width: 220px;margin: auto;margin-top: 30px">
            <select style="font-size: 12px" class="layui-form-select" id="companyName" lay-filter="companyName"
                    lay-search="" name="companyName">
            </select>
        </div>
        <div class="layui-form-item" style="width: 220px;margin: auto;margin-top: 60px">
            <input id="qieHuanBtn" style="border: 0;background-color: #60c7d0;color: #FFFFFF;
            text-align: center;line-height: 24px;height: 24px;width: 220px" value="确&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;定"
                   readonly/>
        </div>
    </form>
</div>

</body>
<script>

    //退出登录
    function logout() {
        location.href = "http://localhost:8035/login.html";
        $.ajax({
            url: '/power/logout',
            dataType: 'json',
            success: function (data) {
                console.log(data);
            }
        });
    }

    layui.use(['layer', 'element', 'table', 'form', 'laydate', 'jquery'], function () {
        var layer = layui.layer;
        var element = layui.element;
        var form = layui.form;
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var table = layui.table;

        //登录后获取登录token去解析登录信息
        $.post("/login/getUInfo", function (data) {
            // console.log(data)
            if (data != null) {
                if (data.code == 200) {
                    //回显登陆人
                    $("#dengluName").html(data.data);

                    //公司切换模块---------------------------------------------
                    var index;
                    $("#qieHuan").unbind('click').click(function () {
                        index = layer.open({
                            type: 1,
                            title: false,
                            closeBtn: 0,
                            shade: [0.3, '#000'],//黑色背景（0.3代表颜色深度）
                            shadeClose: true,//点击遮罩关闭大图
                            area: ['28%', '35%'], //宽高
                            content: $('#qieHuanCompany')
                        });
                    })

                    //根据当前公司名字拿到对应的做账申报id
                    $("#qieHuanBtn").click(function () {
                        var zuoZhangShenBaoId = $('select[name="companyName"] option:selected').val();
                        var companyName = $('select[name="companyName"] option:selected').text();
                        var daiLiShangCid = $("#companyName option:selected").attr("id");
                        $("#companyName1").html(companyName);
                        if (companyName === "请选择公司" || companyName === null) {
                        } else {
                            //页面左侧导航动态拼接模块----------------------------------------------------
                            layui.use(['element', 'form'], function () {
                                var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
                                var form = layui.form; //导航的hover效果、二级菜单等功能，需要依赖element模块
                                $.ajax({
                                    url: '/power/queryZuoZhangShenBaoId',
                                    type: 'get',
                                    data: {
                                        "zuoZhangShenBaoId": zuoZhangShenBaoId,
                                        "companyName": companyName,
                                        "daiLiShangCid": daiLiShangCid
                                    },
                                    dataType: 'json',
                                    success: function (res) {
                                        layer.close(index);
                                        $(".layui-side-scroll").html("")

                                        //页面动态导航拼接回显
                                        if (res.code === 0) {
                                            console.log(res.data)
                                            //layui 根据权限返回值来动态生成菜单栏
                                            var html = '';
                                            html += '<ul class="layui-nav layui-nav-tree" >'
                                            // 循环遍历后端权限前端添加生成菜单
                                            $.each(res.data, function (i, item) {
                                                html = html + '<li class="layui-nav-item my_hint' + i + '">';
                                                if(item.yeMianName === '物品交接'){
                                                    html += '<a href="javascript:;" id="dian" data-url="' + item.yeMianUrl + '" data-title="' + item.yeMianName + '  " class="site-demo-active  my_active" style="font-size: 13px;" data-id="' + item.keHuDuanYeMianLuJingId + '">' +
                                                        '<span id="sp" style="font-size: 13px">' + item.yeMianName + '</span></a>';
                                                }else{
                                                    html += '<a href="javascript:;"  data-url="' + item.yeMianUrl + '" data-title="' + item.yeMianName + '  " class="site-demo-active  my_active" style="font-size: 13px;" data-id="' + item.keHuDuanYeMianLuJingId + '">' +
                                                        '<span id="manu' + i + '" style="font-size: 13px">' + item.yeMianName + '</span></a>';
                                                }
                                                //fid为0 说明有二级菜单
                                                if (item.fid === 0 && item.clist !== null) {
                                                    console.log("---------------------")
                                                    console.log(item.clist)
                                                    html += '<dl class="layui-nav-child my_nav_back" style="margin-left: -41px;font-size: 12px;">';
                                                    //item.clist 是二级菜单的集合  item2是所有二级的对象
                                                    $.each(item.clist, function (j, item2) {
                                                        html += '<dd>'
                                                        html += '<a href="javascript:;" data-url="' + item2.yeMianUrl + '"  data-title="' + item2.yeMianName + ' "  class="site-demo-active  my_active " data-id="' + item2.keHuDuanYeMianLuJingId + '">' +
                                                            '<span style="margin-left: 53px;font-size: 12px">' + item2.yeMianName + '</span></a>';
                                                        html += '</dd>'
                                                    });
                                                    html += '</dl>';
                                                }
                                                html += '</li>';
                                            });
                                            html += '</ul>';

                                            //动态拼接 必须从ul开始
                                            $(".layui-side-scroll").append(html);
                                            $(".layui-side-scroll").trigger("create");

                                            element.init();

                                            //给页面头部下拉框绑定点击事件
                                            var cli = "";

                                            function run() {
                                                document.getElementById("sp").click();
                                            }

                                            function compaynRun() {
                                                var obs = document.getElementById("companyName");
                                                cli = obs.options[obs.selectedIndex].value;
                                                // console.log(">>>>>>>>>>>>>>>>>>>>>>>>>"+cli);
                                                run()
                                            }

                                            compaynRun()

                                            $("#dian").click();

                                            //layui 导航栏所有点击事件
                                            layui.use(['element', 'form'], function () {
                                                var $ = layui.jquery,
                                                    form = layui.form;

                                                //触发事件
                                                var active = {
                                                    tabAdd: function (json) {
                                                        let newurl = json.url;
                                                        json.url = newurl;
                                                        //二级菜单表头不跳转
                                                        if (json.url === 1) {
                                                        } else {
                                                            $("#iframeMain").attr("src", newurl);
                                                        }
                                                    },
                                                };

                                                //当点击有site-demo-active属性的标签时，即左侧菜单栏中内容 ，触发点击事件
                                                //点击事件:
                                                $('.site-demo-active').on('click', function () {
                                                    var dataid = $(this);
                                                    if (dataid.attr("data-url") == 1) {
                                                    } else {
                                                        var json = {
                                                            url: dataid.attr("data-url"),
                                                            id: dataid.attr("data-id"),
                                                            title: dataid.attr("data-title")
                                                        };
                                                        active.tabAdd(json);
                                                    }
                                                });

                                                form.render();
                                            })
                                        }
                                    }
                                });
                                //-----------------------------------------------------------------------
                            })
                        }
                    })

                    //主页面头部导航栏下拉框公司回显-----------------------------------------------------------
                    $.get("/power/queryCompanyName", function (obj) {
                        // console.log(obj.data.daiLiShangCid)
                        if (obj.code === 0) {
                            for (let i = 0; i < obj.data.length; i++) {
                                $("#companyName").append('<option style="font-size: 12px" value="' + obj.data[i].zuoZhangShenBaoId + '" id="' + obj.data[i].daiLiShangCid + '" onclick="run()">' + obj.data[i].companyName + '</option>')
                            }
                            $("#companyName").find("option[value=" + obj.data[0].zuoZhangShenBaoId + "]").prop("selected", "true");
                            $("#companyName1").html(obj.data[0].companyName);
                            form.render('select');
                            var zuoZhangShenBaoId = $("#companyName option:checked").val();
                            var companyName = $("#companyName option:selected").text();
                            var daiLiShangCid = $("#companyName option:selected").attr("id");
                            // console.log(daiLiShangCid)
                            $.ajax({
                                url: '/power/queryZuoZhangShenBaoId',
                                type: 'get',
                                data: {
                                    "zuoZhangShenBaoId": zuoZhangShenBaoId,
                                    "companyName": companyName,
                                    "daiLiShangCid": daiLiShangCid
                                },
                                dataType: 'json',
                                success: function (res) {
                                    //页面动态导航拼接回显
                                    if (res.code === 0) {
                                        console.log(res.data)
                                        //layui 根据权限返回值来动态生成菜单栏
                                        var html = '';
                                        html += '<ul class="layui-nav layui-nav-tree" >'
                                        // 循环遍历后端权限前端添加生成菜单
                                        $.each(res.data, function (i, item) {
                                            html = html + '<li class="layui-nav-item my_hint' + i + '">';
                                            if(item.yeMianName === '物品交接'){
                                                html += '<a href="javascript:;" id="dian" data-url="' + item.yeMianUrl + '" data-title="' + item.yeMianName + '  " class="site-demo-active  my_active" style="font-size: 13px;" data-id="' + item.keHuDuanYeMianLuJingId + '">' +
                                                    '<span id="sp" style="font-size: 13px">' + item.yeMianName + '</span></a>';
                                            }else{
                                                html += '<a href="javascript:;"  data-url="' + item.yeMianUrl + '" data-title="' + item.yeMianName + '  " class="site-demo-active  my_active" style="font-size: 13px;" data-id="' + item.keHuDuanYeMianLuJingId + '">' +
                                                    '<span id="manu' + i + '" style="font-size: 13px">' + item.yeMianName + '</span></a>';
                                            }
                                            //fid为0 说明有二级菜单
                                            if (item.fid === 0 && item.clist !== null) {
                                                console.log("-------------------")
                                                console.log(item.clist)
                                                html += '<dl class="layui-nav-child my_nav_back" style="margin-left: -41px;font-size: 12px;">';
                                                //item.clist 是二级菜单的集合  item2是所有二级的对象
                                                $.each(item.clist, function (j, item2) {
                                                    html += '<dd>'
                                                    html += '<a href="javascript:;" data-url="' + item2.yeMianUrl + '"  data-title="' + item2.yeMianName + ' "  class="site-demo-active  my_active " data-id="' + item2.keHuDuanYeMianLuJingId + '">' +
                                                        '<span style="margin-left: 53px;font-size: 12px">' + item2.yeMianName + '</span></a>';
                                                    html += '</dd>'
                                                });
                                                html += '</dl>';
                                            }
                                            html += '</li>';
                                        });
                                        html += '</ul>';

                                        //动态拼接 必须从ul开始
                                        $(".layui-side-scroll").append(html);
                                        $(".layui-side-scroll").trigger("create");

                                        element.init();

                                        //给页面头部下拉框绑定点击事件
                                        var cli = "";

                                        function run() {
                                            document.getElementById("sp").click();
                                        }

                                        function compaynRun() {
                                            var obs = document.getElementById("companyName");
                                            cli = obs.options[obs.selectedIndex].value;
                                            // console.log(">>>>>>>>>>>>>>>>>>>>>>>>>"+cli);
                                            run()
                                        }

                                        compaynRun()

                                        $("#dian").click();

                                        //layui 导航栏所有点击事件
                                        layui.use(['element', 'form'], function () {
                                            var $ = layui.jquery,
                                                form = layui.form;

                                            //触发事件
                                            var active = {
                                                tabAdd: function (json) {
                                                    let newurl = json.url;
                                                    json.url = newurl;
                                                    //二级菜单表头不跳转
                                                    if (json.url === 1) {
                                                    } else {
                                                        $("#iframeMain").attr("src", newurl);
                                                    }
                                                },
                                            };

                                            //当点击有site-demo-active属性的标签时，即左侧菜单栏中内容 ，触发点击事件
                                            //点击事件:
                                            $('.site-demo-active').on('click', function () {
                                                var dataid = $(this);
                                                if (dataid.attr("data-url") == 1) {
                                                } else {
                                                    var json = {
                                                        url: dataid.attr("data-url"),
                                                        id: dataid.attr("data-id"),
                                                        title: dataid.attr("data-title")
                                                    };
                                                    active.tabAdd(json);
                                                }
                                            });

                                            form.render();
                                        })
                                    }
                                }
                            })
                        }
                    })
                    //------------------------------------------------------------------------------------------
                }
            }
        });

        //触发事件
        var active = {
            tabAdd: function (json) {
                let newurl = json.url;
                json.url = newurl;
                //二级菜单表头不跳转
                $("#iframeMain").attr("src", newurl);
            },
        };

        //当点击有site-demo-active属性的标签时，即左侧菜单栏中内容 ，触发点击事件
        //点击事件:
        $('.site-demo-active').on('click', function () {
            var dataid = $(this);
            var json = {
                url: dataid.attr("data-url"),
                id: dataid.attr("data-id"),
                title: dataid.attr("data-title")
            };
            active.tabAdd(json);
        });
        form.render();
    })
</script>
</html>



















